package com.focusai.efairy.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Created by luo_guangwen on 2017/10/18.
 */

public class NetworkUtils {
    /**
     * 判断WIFI网络是否正常
     * @param context
     * @return
     */
    public static boolean isWifiNetConnect(Context context) {
        ConnectivityManager connectivity = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (connectivity == null) {
            return false;
        } else {
            NetworkInfo netWrokInfo = connectivity.getActiveNetworkInfo();
            if (netWrokInfo != null && netWrokInfo.getTypeName().equals("WIFI")
                    && netWrokInfo.isAvailable()) {
                return true;
            }
        }
        return false;
    }
}
